<template lang="">
    <div>
  <el-menu
            active-text-color="#ffd04b"
            background-color="#545c64"
            :default-active="defaultActive"
            text-color="#fff"
            router
          >
            <el-menu-item index="/home">
              <el-icon><setting /></el-icon>
              <span>首页</span>
            </el-menu-item>
            <el-sub-menu v-for="item in store.getters.getUser.menus" :key="item.id" :index="item.id.toString()">
              <!-- 新语法 #title 等价于   slot='title' -->
              <template #title>
                <el-icon :size="20"><component :is="item.icon"></component> </el-icon>
                <span>{{item.title}}</span>
              </template>
                <el-menu-item v-for="menu in item.children" :key="menu.id" :index="menu.url">{{menu.title}}</el-menu-item>
              <!-- <el-menu-item index="/role">角色管理</el-menu-item>
               <el-menu-item index="/user">管理员管理</el-menu-item> -->
            </el-sub-menu>
             <!-- <el-sub-menu index="2">
          <template #title>
                <el-icon><ShoppingBag /></el-icon>
            <span>商城管理</span>
          </template>
            <el-menu-item index="2-1">商品分类</el-menu-item>
            <el-menu-item index="2-2">商品规格</el-menu-item>
            <el-menu-item index="2-3">商品管理</el-menu-item>
            <el-menu-item index="2-4">会员管理</el-menu-item>
        </el-sub-menu> -->
     
          </el-menu>
  </div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import { useStore } from 'vuex'
import { useRoute } from 'vue-router'
const route = useRoute()
const store = useStore()
// console.log(route, 'trrrrrrr')
let defaultActive = ref('/home')
// 封装一个刷新url地址事件
const newPath = () => {
  defaultActive.value = route.path
}
newPath()
</script>
<style  scoped>
.el-menu {
  min-width: 150px;
  min-height: 600px;
}

.el-menu-item {
  min-width: 150px;
}
</style>